/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.data.feature;

import java.util.HashMap;
import java.util.Map;
/**
 * 要素元数据模式
 * @author chunquedong
 * 
 */
public class FeatureSchama {
	Map<String,Integer> attributes=new HashMap<String,Integer>();
	Field[] fields;
	private int geometryColumn;
	private int idColumn;
	
	public FeatureSchama(Field[] fields,int idColumn,int geometryColumn){
		this.fields= fields.clone();
		this.idColumn=idColumn;
		this.geometryColumn=geometryColumn;
		for(Field f:fields){
			attributes.put(f.getName(), f.getIndex());
		}
	}
	
	public int getGeometryColumn() {
		return geometryColumn;
	}

	public int getIdColumn() {
		return idColumn;
	}

	public int getFieldIndex(String name){
		return attributes.get(name);
	}
	
	public String getFieldName(int index){
		return fields[index].getName();
	}
	
	public int getFieldType(int index){
		return fields[index].getType();
	}
	
	public int size(){
		return fields.length;
	}
}